<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统首页</title>
    <link rel="stylesheet" href="{$CSS}/bootstrap3.3.7.min.css">
    <style>
        td,th{
			text-align: center;vertical-align: middle !important;
			}
        .paging{
           list-style:none;
           display:inline ;
           padding-left:2px    
        }
/*
        .paging:after{
            content:"";
            clear: both
        }
*/
        .paging li{
            display:inline-block
        }
        .paging a{
            padding:5px 10px;
            border: 1px solid #ddd;
            margin-left: -1px;
            text-decoration: none;
        }
        .active{
            border-color: #337ab7 !important;
        }
    </style>
</head>

<body>
    <div style="padding:10px;border-bottom:1px solid #eee;font-size:15px;font-weight:700">短信模板配置&nbsp;&nbsp;<span style="color:red">注意事项:手动复制下面模板内容添加到阿里云短信后台报备即可(注册验证码为验证码类型，其他均为【短信通知】类型)</span></div>
	 <form action="" method="post" >
    <div style="padding:20px">
        <div style="margin-top:15px">
            <table class="table table-bordered table-hover" style="table-layout：fixed">
              <thead>
                <tr>
                  <th class="col-md-2">主题</th>
                  <th>模板内容</th>
				  <th>标签说明</th>
                  <th class="col-md-2">模板code</th>
                  <th class="col-md-1">操作</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>注册验证码</td>
				  <td style="word-wrap:break-word;word-break:break-all;" name="contents">尊敬的客户您好，您的短信验证码是:${ code}</td>
				  <td style="word-wrap:break-word;word-break:break-all;" name="contents">${ code}自动生成的验证码</td>
				  <td><input type="text" name="template_register_code" id="template_register_code" value="{$tpls['template_register_code']}"></td>
                  <td>
                      <button type="button" class="btn btn-primary" onclick="ceshi('template_register_code')">测试</button>
                  </td>
                </tr>

              </tbody>
            </table>
        </div>
		   <input class="btn btn-success mar" type="submit" value="保存">
    </div>
	</form>
</body>
</html>
 <script src="/layui/layui.all.js"></script>
<script type="text/javascript">
function ceshi(name){
	var code = $("#"+name).val();
	layer.open({
		title: '请输入手机号' 
		,content: '<input id="phoneNum"/>'
		,btn:['确认','取消']
		,yes: function(index, layero){
				var phoneNum = $('#phoneNum').val();
				if(phoneNum==''){
					alert('手机号不能为空');
					return false;
				}
				if(phoneNum.length!=11){
					alert('手机号需11位');
					return false;
				}
				$.post("sendSms.html",{
					name:name,code:code,phoneNum:phoneNum},function(result){
					if(result=='ok'){
						layer.msg('发送成功');
					}else{
						layer.msg('发送失败,失败原因'+result);
					}
										
				});
			}
	})
}

function Trim(str,is_global){
	var result;
    result = str.replace(/(^\s+)|(\s+$)/g,"");
    if(is_global.toLowerCase()=="g"){
         result = result.replace(/\s/g,"");
    }
	return result;
}
$("td[name='contents']").each(function(){
    $(this).text(Trim($(this).text(),"g"));
  });
</script>